import logging
from PySide6.QtCore import Qt, QUrl, QRect, QPropertyAnimation, QEasingCurve, QByteArray
from PySide6.QtGui import QPixmap, QColor, QBrush,QStandardItemModel, QStandardItem,QAction

from pathlib import Path
import sys
from PySide6.QtWidgets import (QMainWindow, QApplication, QMessageBox, QLabel, QListView, QTreeWidget, QTreeWidgetItem, QListWidget, QMenu)
import os


from pathlib import Path

class ThemeManager:
    def __init__(self):
        self.theme_path = Path(__file__).parent / 'themes'
        
    def load_theme(self, theme_name):
        try:
            qss_file = self.theme_path / f'{theme_name}_theme.qss'
            with open(qss_file, 'r', encoding='utf-8') as f:
                style = f.read()
                QApplication.instance().setStyleSheet(style)
                logging.info(f'成功加载 {theme_name} 主题')
        except Exception as e:
            logging.error(f'主题加载失败: {str(e)}')
            QMessageBox.warning(None, '主题错误', f'无法加载{theme_name}主题文件')